package com.zgys.mes.rest;


import java.util.LinkedHashMap;
import java.util.List;

import com.zgys.mes.client.dto.PageInfoDto;
import com.zgys.mes.client.dto.UserDto;
import com.zgys.mes.service.UserService;
import com.zgys.mes.util.error.RtResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping(value = "/baseUrl")
@Api(value = "mes服务", description = "文档管理接口，主要用于HMI文档管理业务")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping(value = "/User/list", method = RequestMethod.GET)
    @ApiOperation(value = "查询人员列表信息", notes = "人员信息，test test test ")
    public
    @ApiResponse(code = 200, message = "操作成功")
    RtResponse listUser(@ApiParam("页码") @RequestParam("page") Integer page, @ApiParam("每页大小") @RequestParam("size") Integer size) {

        PageInfoDto p = userService.listUser(page, size);

        return RtResponse.setSuccessResponse(p);
    }

    @RequestMapping(value = "/User/{userId}", method = RequestMethod.GET)
    @ApiOperation(value = "查询人员", notes = "查询人员 查询人员")
    public
    @ApiResponse(code =  200, message = "操作成功")
    RtResponse getFunctionTypeByParentType(
            @ApiParam(value = "userId", required = true)
            @PathVariable("userId")
                    int userId) {
        UserDto userDto = userService.getUser(userId);
        return RtResponse.setSuccessResponse(userDto);
    }

    @RequestMapping(value = "/User/list2", method = RequestMethod.GET)
    @ApiOperation(value = "查询人员列表信息", notes = "人员信息，test test test ")
    public
    @ApiResponse(code = 200, message = "操作成功")
    RtResponse list2User(@ApiParam("页码") @RequestParam("page") Integer page, @ApiParam("每页大小") @RequestParam("size") Integer size) {

        List<LinkedHashMap<String,Object>> A =userService.selectall(page, size);

        return RtResponse.setSuccessResponse(A);
    }

}
